#!/usr/bin/perl -w
#Jimmy Saw - 10-01-2007 

use Bio::SearchIO;

my $in = new Bio::SearchIO(-format => 'hmmer', -file => $ARGV[0]);
my $evalue = $ARGV[1];

while(my $result = $in->next_result){
#    print $result->query_name(), " for HMM ", $result->hmm_name(), "\n";
    print $result->query_name(), "\t";
    while(my $hit = $result->next_hit){
#        print $hit->name(), "\n";
#        print $hit->description(), "\n";
        while(my $hsp = $hit->next_hsp){
#            print "length is ", $hsp->length(), "\n";
#            print "E-value is ", $hsp->evalue(), "\n";
            if($hsp->evalue() <= $evalue){
                print "Residues ", $hsp->start(), " to ", $hsp->end(), " (E_value = ", $hsp->evalue(), ")", " place " ; 
                print $result->query_name(), " in the ", $hit->name, " family which is described as ", $hit->description, ".", "\\n";
            }
        }
    }
}
print "\n";
